import 'package:casdon/core/network/base_response.dart';

abstract class IApiClient {
  Future<T?> get<T>(
    String path, {
    Map<String, dynamic>? pathParams,
    Map<String, dynamic>? query,
    Map<String, dynamic>? headers,
  });

  Future<BaseResponse<T>?> getTyped<T>(
    String path, {
    Map<String, dynamic>? pathParams,
    Map<String, dynamic>? query,
    bool encrypt = false,
    Map<String, dynamic>? headers,
    required T Function(Object? json) fromJsonT,
  });
  // 主要用于某些接口没有 error， message，data外层结构的特别处理。（应答后端改）
  Future<T?> getTypedNOBase<T>(
    String path, {
    Map<String, dynamic>? pathParams,
    Map<String, dynamic>? query,
    bool encrypt = false,
    Map<String, dynamic>? headers,
    required T Function(Object? json) fromJsonT,
  });

  Future<T?> post<T>(
    String path, {
    Map<String, dynamic>? pathParams,
    dynamic data,
    bool encrypt = false,
    Map<String, dynamic>? headers,
  });

  Future<BaseResponse<T>?> postTyped<T>(
    String path, {
    Map<String, dynamic>? pathParams,
    dynamic data,
    bool encrypt = false,
    Map<String, dynamic>? headers,
    required T Function(Object? json) fromJsonT,
  });

  Future<T?> put<T>(
    String path, {
    Map<String, dynamic>? pathParams,
    dynamic data,
    Map<String, dynamic>? headers,
  });

  Future<T?> delete<T>(
    String path, {
    Map<String, dynamic>? pathParams,
    Map<String, dynamic>? query,
    Map<String, dynamic>? headers,
  });

  Future<BaseResponse<T>?> putTyped<T>(
    String path, {
    Map<String, dynamic>? pathParams,
    dynamic data,

    Map<String, dynamic>? headers,
    required T Function(Object? json) fromJsonT,
  });

  Future<BaseResponse<T>?> deleteTyped<T>(
    String path, {
    Map<String, dynamic>? pathParams,
    Map<String, dynamic>? query,
    Map<String, dynamic>? headers,
    required T Function(Object? json) fromJsonT,
  });

  Future<void> sse(
    String path, {
    Map<String, dynamic>? pathParams,
    Map<String, dynamic>? query,
    Map<String, dynamic>? headers,
    required void Function(String data) onMessage,
    required void Function(Exception e) onError,
    required void Function() onDone,
    required void Function() onConnectSuccess,
  });
}
